﻿using System;
using System.Collections.Generic;
using NUnit.Framework;
using Xenta.Enums;
using Xenta.Operations;

namespace Xenta.Tests.Operations
{
    [TestFixture]
    public class ForumTests : OperationTest
    {
        protected override IEnumerable<Type> ModelMappings
        {
            get
            {
                return NHMappings.ALL;
            }
        }

        [TestCase(1)]
        public void Can_CRUD(int displayOrder)
        {
            var forum = Processor.Execute(new CreateForum
            {
                ParentID = 0,
                DisplayOrder = displayOrder
            }).Result;

            Assert.NotNull(forum);
            forum.DisplayOrder.AreEqual(displayOrder);
            forum.AreEqual(Processor.Execute(new GetForum
            {
                EntityID = forum.EntityID
            }).Result);

            displayOrder = displayOrder + 1;
            var upd_forum = Processor.Execute(new UpdateForum
            {
                EntityID = forum.EntityID,
                DisplayOrder = displayOrder,
                Flags = ForumFlags.Active
            }).Result;

            Assert.NotNull(upd_forum);
            upd_forum.AreEqual(forum);
            upd_forum.DisplayOrder.AreEqual(displayOrder);
            upd_forum.Flags.AreEqual(ForumFlags.Active);

            Processor.Execute(new DeleteForum
            {
                EntityID = forum.EntityID
            });
        }
    }
}
